package home;

import java.text.DecimalFormat;

public class Account {
	private int CustomerID;
	private String CustomerName;
	private int OpeningDate;
	private double OpeningBalance;
	private Portfolio portfolio; //Custom class that helps calculate and display the accounts portfolio.
	
	/*
	 * Constructors
	 */
	public Account(int customerID, String customerName, int openingDate,double openingBalance) {
		super();
		CustomerID = customerID;
		CustomerName = customerName;
		OpeningDate = openingDate;
		OpeningBalance = openingBalance;
		portfolio = new Portfolio();
		portfolio.initPortfolio();
	}
	
	public Account() {
		portfolio = new Portfolio();
		portfolio.initPortfolio();
	}
	
	public Portfolio getPortfolio() {
		return portfolio;
	}
	


	/**
	 * Getters and setters
	 * @return
	 */
	public int getCustomerID() {
		return CustomerID;
	}
	public void setCustomerID(int customerID) {
		CustomerID = customerID;
		portfolio.setCustomerID(CustomerID);
	}
	public String getCustomerName() {
		return CustomerName;
	}
	public void setCustomerName(String customerName) {
		CustomerName = customerName;
	}
	public int getOpeningDate() {
		return OpeningDate;
	}
	public void setOpeningDate(int openingDate) {
		OpeningDate = openingDate;
	}
	public double getOpeningBalance() {
		return OpeningBalance;
	}
	public void setOpeningBalance(double openingBalance) {
		OpeningBalance = openingBalance;
	}
	
	double RoundTo2Decimals(double val) {
        DecimalFormat df2 = new DecimalFormat("###.##");
    return Double.valueOf(df2.format(val));
	}
	
@Override
	public String toString() {
		return "Customer ID:" + CustomerID + ", Customer Name:" + CustomerName + ", Opening Date:" + OpeningDate + ", Opening Balance:$" + RoundTo2Decimals(OpeningBalance);
	}

	
}

